package cn.com.css.taxInspection.workflow.controller;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import cn.com.css.taxInspection.common.aop.annotation.LogAnnotation;
import cn.com.css.taxInspection.common.result.DataResult;
import cn.com.css.taxInspection.gt3.entity.JcAjxxEntity;
import cn.com.css.taxInspection.gt3.service.JcAjxxService;
import cn.com.css.taxInspection.system.service.impl.HttpSessionService;
import cn.com.css.taxInspection.workflow.entity.WorkflowInspectionHearEntity;
import cn.com.css.taxInspection.workflow.entity.WorkflowMeetEntity;
import cn.com.css.taxInspection.workflow.service.WorkflowMeetService;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;

/**
 * ${comments}
 *
 * @author shaochangyang
 * @email l2l84o7o5@live.com
 * @date 2023-10-04 00:23:58
 */
@Controller
@RequestMapping("/workflow/meet")
public class WorkflowMeetController {
	
	@Autowired
	private HttpSessionService httpSessionService;
	
	@Autowired
	private WorkflowMeetService workflowMeetService;
	@Autowired
	private JcAjxxService jcAjxxService;
	
	@SuppressWarnings({ "unchecked", "rawtypes" })
	@ApiOperation(value = "会议审-个人待办")
	@LogAnnotation(title = "会议审", action = "个人待办")
	@PostMapping("/listwait")
	@RequiresPermissions("workflow:meet:wait")
	@ResponseBody
	@DS("oracle")
	public DataResult listwait11(@RequestBody WorkflowInspectionHearEntity workflowInspectionHear) {
		String currentUserId = httpSessionService.getCurrentUserId();
		Page page = new Page(workflowInspectionHear.getPage(), workflowInspectionHear.getLimit());
		LambdaQueryWrapper<WorkflowMeetEntity> queryWrapper = Wrappers.lambdaQuery();
		// 查询条件示例
		queryWrapper.like(WorkflowMeetEntity::getMeetMan, currentUserId);
		queryWrapper.notLike(WorkflowMeetEntity::getMeetManDeno, currentUserId);
		IPage<WorkflowMeetEntity> iPage = workflowMeetService.page(page, queryWrapper);
		List<WorkflowMeetEntity> records = iPage.getRecords();
		for (WorkflowMeetEntity workflowMeetEntity : records) {
			String relevance = workflowMeetEntity.getRelevance();
			String id = workflowMeetEntity.getId();
			JcAjxxEntity jcAjxxEntity = jcAjxxService.getByJcajxxuuid(relevance);
			BeanUtils.copyProperties(jcAjxxEntity, workflowMeetEntity);
			workflowMeetEntity.setId(id);
		}
		return DataResult.success(iPage);
	}
	
	@SuppressWarnings({ "rawtypes", "unchecked" })
	@ApiOperation(value = "会议审-个人已办")
	@LogAnnotation(title = "会议审", action = "个人已办")
	@PostMapping("/listthen")
	@RequiresPermissions("workflow:meet:then")
	@ResponseBody
	@DS("oracle")
	public DataResult listthen11(@RequestBody WorkflowInspectionHearEntity workflowInspectionHear) {
		String currentUserId = httpSessionService.getCurrentUserId();
		Page page = new Page(workflowInspectionHear.getPage(), workflowInspectionHear.getLimit());
		LambdaQueryWrapper<WorkflowMeetEntity> queryWrapper = Wrappers.lambdaQuery();
		// 查询条件示例
		queryWrapper.like(WorkflowMeetEntity::getMeetManDeno, currentUserId);
		IPage<WorkflowMeetEntity> iPage = workflowMeetService.page(page, queryWrapper);
		List<WorkflowMeetEntity> records = iPage.getRecords();
		for (WorkflowMeetEntity workflowMeetEntity : records) {
			String relevance = workflowMeetEntity.getRelevance();
			JcAjxxEntity jcAjxxEntity = jcAjxxService.getByJcajxxuuid(relevance);
			BeanUtils.copyProperties(jcAjxxEntity, workflowMeetEntity);
		}
		return DataResult.success(iPage);
	}
	
}
